class_name FreezeState
extends AnomalyState


## 冻结角色，角色无法移动，同时降低_reduce_resistance的冰属性抗性，持续duration秒


@export var _reduce_resistance: float
@export var _freeze_material: Material



var _modified_value: float
var _sprite: Sprite2D
var _original_material: Material



func _ready() -> void:
    _sprite = _target.get_node("Sprite2D")


func _init_data() -> void:
    _modified_value = _target.data.ice_resistance.value * _reduce_resistance
    _target.data.ice_resistance.add_modifier(-_modified_value)
 
    if _sprite:
        _original_material = _sprite.material
        _sprite.material = _freeze_material
    
    _target.be_static(true)
    var info := DamageInfo.new()
    info.target = _target
    FloatTextSystem.show_anomaly_text(info, type)



func _end() -> void:
    _target.data.ice_resistance.add_modifier(_modified_value)
    _sprite.material = _original_material
    _target.be_static(false)

